package com.chyb.cloud.apis;

import com.chyb.cloud.entities.PayDTO;
import com.chyb.cloud.resp.ResultData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "cloud-payment-service")/*标记为OpenFeign接口，value为服务名*/
public interface openFeignApi {
    @PostMapping("/pay/add")/*这里的网址要与实际调用服务的API接口网址相同*/
    ResultData add(@RequestBody PayDTO payDTO);

    @GetMapping("/pay/getAll")
    ResultData getAll();

    @GetMapping("/pay/getInfo")
    String getInfo();

    /**
     * 测试熔断、降级
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/circuit/{id}")
    String myCircuit(@PathVariable("id") Integer id);

    /**
     * 测试隔离
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/bulkhead/{id}")
    String myBulkhead(@PathVariable("id") Integer id);

    /**
     * Resilience4j Ratelimit(限流) 的例子
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/ratelimit/{id}")
    String myRatelimit(@PathVariable("id") Integer id);


}
